package com.orange.cloud.common.msg;

import lombok.*;

import java.io.Serializable;


@Builder
@AllArgsConstructor
@NoArgsConstructor
public class Message<T> implements Serializable {
    private static final long serialVersionUID = -1L;
    @Getter
    @Setter
    private Head head;
    @Getter
    private T body;

    public static final int SUCCESS_MIN=0;
    public static final int SUCCESS_MAX=99;

    public Message<T> setBody(T body) {
        this.body = body;
        return this;
    }

    public Boolean success() {
        return this.head != null && (SUCCESS_MAX-this.head.getRespCode())>=SUCCESS_MIN;
    }

    public Boolean unSuccess() {
        return !success();
    }

    public String msg(){
        return this.head.getRespMsg();
    }
}
